namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0039 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.IcmInventoryStockTaking",
                c => new
                    {
                        StockTakingCode = c.Int(nullable: false, identity: true),
                        StockTakingStartDate = c.DateTime(),
                        StockTakingEndDate = c.DateTime(),
                        StockTakingDesc = c.String(),
                        StockTakingRemark = c.String(),
                        JobSiteId = c.Int(),
                        IcmWhId = c.Int(),
                        CreatedBy = c.Int(),
                        CreatedWhen = c.DateTime(),
                        UpdatedBy = c.Int(),
                        UpdatedWhen = c.DateTime(),
                        ApprovedBy = c.Int(),
                        ApprovedWhen = c.DateTime(),
                        ApprovedRemark = c.String(),
                        CancelBy = c.Int(),
                        CancelWhen = c.DateTime(),
                        CancelRemark = c.String(),
                        RecordStatus = c.String(),
                    })
                .PrimaryKey(t => t.StockTakingCode)
                .ForeignKey("dbo.hrm_mp_job_sites", t => t.JobSiteId)
                .ForeignKey("dbo.IcmWarehouse", t => t.IcmWhId)
                .Index(t => t.JobSiteId)
                .Index(t => t.IcmWhId);
            
            CreateTable(
                "dbo.IcmInventoryStockTakingItem",
                c => new
                    {
                        StockTakingItemId = c.Int(nullable: false, identity: true),
                        StockTakingCode = c.String(),
                        ResItemId = c.Int(),
                        QuanlityAmountStock = c.Int(),
                        QuantityAmountReal = c.Int(),
                        Remark = c.String(),
                        RecordStatus = c.String(),
                        CreatedBy = c.Int(),
                        CreatedWhen = c.DateTime(),
                        UpdatedBy = c.Int(),
                        UpdatedWhen = c.DateTime(),
                    })
                .PrimaryKey(t => t.StockTakingItemId)
                .ForeignKey("dbo.IcmMasResourceItem", t => t.ResItemId)
                .Index(t => t.ResItemId);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.IcmInventoryStockTakingItem", new[] { "ResItemId" });
            DropIndex("dbo.IcmInventoryStockTaking", new[] { "IcmWhId" });
            DropIndex("dbo.IcmInventoryStockTaking", new[] { "JobSiteId" });
            DropForeignKey("dbo.IcmInventoryStockTakingItem", "ResItemId", "dbo.IcmMasResourceItem");
            DropForeignKey("dbo.IcmInventoryStockTaking", "IcmWhId", "dbo.IcmWarehouse");
            DropForeignKey("dbo.IcmInventoryStockTaking", "JobSiteId", "dbo.hrm_mp_job_sites");
            DropTable("dbo.IcmInventoryStockTakingItem");
            DropTable("dbo.IcmInventoryStockTaking");
        }
    }
}
